package day17.myenum;

import java.util.Arrays;

/**
 * @author Xiao
 * @date 2021/8/12
 */
public class EnumDemo03 {
    /**
     * 枚举的方法：
     * String name()    获取枚举项的名称
     * int ordinal()    返回枚举项在枚举类中的索引值
     * int compareTo(E o)   比较两个枚举项，返回的是索引值的差值
     * String toString()    返回枚举常量的名称
     * static <T> T valueOf(Class<T> type,String name)   获取指定枚举类中的指定名称的枚举值
     * values() 获得所有的枚举项
     */
    public static void main(String[] args) {
        String name = Season03.SPRING.name();//SPRING
        int index = Season03.SUMMER.ordinal();//1
        int compareIndex = Season03.SPRING.compareTo(Season03.WINTER);//-3
        String s = Season03.SPRING.toString();//SPRING
        Season03 valueOf = Enum.valueOf(Season03.class, "AUTUMN");//AUTUMN
        Season03[] values = Season03.values();//[SPRING, SUMMER, AUTUMN, WINTER]
        System.out.println(name);
        System.out.println(index);
        System.out.println(compareIndex);
        System.out.println(s);
        System.out.println(valueOf);
        System.out.println(valueOf == Season03.AUTUMN);
        System.out.println(Arrays.toString(values));
    }
}
